package indi.madoka.weeb.module.base.plugin;

import indi.madoka.weeb.annotations.Keyword;
import indi.madoka.weeb.annotations.Plugin;
import indi.madoka.weeb.bean.send.Sender;
import indi.madoka.weeb.bean.update.message.UpdateMessage;
import indi.madoka.weeb.enums.MatchType;
import indi.madoka.weeb.module.base.service.TraceMoeService;
import lombok.extern.slf4j.Slf4j;

/**
 * @author Arcueid
 */
@Plugin("Trace Moe 找出处API")
@Slf4j
public class TraceMoePlugin {

    private final TraceMoeService traceMoeService;

    public TraceMoePlugin(TraceMoeService traceMoeService) {
        this.traceMoeService = traceMoeService;
    }

    @Keyword(value = "#出处", param = "[图片]", matchType = MatchType.STARTS_WITH, description = "寻找图片出处")
    public void getTraceByImg(UpdateMessage updateMessage){
        String source = traceMoeService.getImageSource(updateMessage);
        new Sender.Builder(updateMessage)
                .addText(source)
                .build()
                .sendAll();
    }
}
